"use strict";
cc._RF.push(module, '9af2ebQ/SlI6497kkb8lEdp', 'dagger');
// script/game/dagger.js

"use strict";

cc.Class({
  "extends": cc.Component,
  properties: {
    speedX: {
      "default": 200,
      type: cc.Integer
    }
  },
  start: function start() {
    this.poolNode = cc.find('Canvas/role');
    this.R_Width = cc.winSize.width * 0.5;
    this.L_Width = cc.winSize.width * -0.5;
    this.roleScaleX = this.poolNode.scaleX;
  },
  show: function show() {
    this.node.active = true;
  },
  hide: function hide() {
    this.node.active = false;
  },
  update: function update(dt) {
    var dgScaleX = Math.abs(this.node.scaleX);
    var dg_x = this.speedX * dt;

    if (this.roleScaleX == 1) {
      this.node.scaleX = dgScaleX;
      this.node.x += dg_x;
    } else if (this.roleScaleX == -1) {
      this.node.scaleX = -dgScaleX;
      this.node.x += -dg_x;
    }

    if (this.node.x >= this.R_Width || this.node.x <= this.L_Width) {
      this.node.removeFromParent();
      this.hide();
      console.log("移除成功");
    }
  }
});

cc._RF.pop();